package DataStructures;

import LinkedList.Medium.LC0160;

public class ListNode {
    public int val;
    public ListNode next;

    public ListNode(int x) {
        val = x;
        next = null;
    }

    public ListNode(int[] vals) {
        val = vals[0];
        next = null;
        ListNode ptr = this;
        for (int i = 1; i < vals.length; i++) {
            ptr.next = new ListNode(vals[i]);
            ptr = ptr.next;
        }
    }

    public ListNode(int[] vals, ListNode anotherList) {
        val = vals[0];
        next = anotherList;
        ListNode ptr = this;
        for (int i = 1; i < vals.length; i++) {
            ptr.next = new ListNode(vals[i]);
            ptr = ptr.next;
            ptr.next = anotherList;
        }
    }
}